package com.ruoyi.system.controller;

import java.util.List;

import jakarta.annotation.security.PermitAll;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.BankWithdrawal;
import com.ruoyi.system.service.IBankWithdrawalService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 银行提现账户Controller
 * 
 * @author zhangjf
 * @date 2025-10-13
 */
@RestController
@RequestMapping("/withdrawal")
public class BankWithdrawalController extends BaseController
{
    @Autowired
    private IBankWithdrawalService bankWithdrawalService;

    /**
     * 查询银行提现账户列表
     */
    @RequiresPermissions("system:withdrawal:list")
    @GetMapping("/list")
    public TableDataInfo list(BankWithdrawal bankWithdrawal)
    {
        startPage();
        List<BankWithdrawal> list = bankWithdrawalService.selectBankWithdrawalList(bankWithdrawal);
        return getDataTable(list);
    }

    /**
     * 导出银行提现账户列表
     */
    @RequiresPermissions("system:withdrawal:export")
    @Log(title = "银行提现账户", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BankWithdrawal bankWithdrawal)
    {
        List<BankWithdrawal> list = bankWithdrawalService.selectBankWithdrawalList(bankWithdrawal);
        ExcelUtil<BankWithdrawal> util = new ExcelUtil<BankWithdrawal>(BankWithdrawal.class);
        util.exportExcel(response, list, "银行提现账户数据");
    }

    /**
     * 获取银行提现账户详细信息
     */
    @RequiresPermissions("system:withdrawal:query")
    @GetMapping(value = "/{withdrawalAcctId}")
    public AjaxResult getInfo(@PathVariable("withdrawalAcctId") Long withdrawalAcctId)
    {
        return success(bankWithdrawalService.selectBankWithdrawalByWithdrawalAcctId(withdrawalAcctId));
    }

    /**
     * 新增银行提现账户
     */
    @RequiresPermissions("system:withdrawal:add")
    @Log(title = "银行提现账户", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BankWithdrawal bankWithdrawal)
    {
        return toAjax(bankWithdrawalService.insertBankWithdrawal(bankWithdrawal));
    }

    /**
     * 修改银行提现账户
     */
    @RequiresPermissions("system:withdrawal:edit")
    @Log(title = "银行提现账户", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BankWithdrawal bankWithdrawal)
    {
        return toAjax(bankWithdrawalService.updateBankWithdrawal(bankWithdrawal));
    }

    /**
     * 删除银行提现账户
     */
    @RequiresPermissions("system:withdrawal:remove")
    @Log(title = "银行提现账户", businessType = BusinessType.DELETE)
	@DeleteMapping("/{withdrawalAcctIds}")
    public AjaxResult remove(@PathVariable Long[] withdrawalAcctIds)
    {
        return toAjax(bankWithdrawalService.deleteBankWithdrawalByWithdrawalAcctIds(withdrawalAcctIds));
    }

    /**
     * 解绑
     */

    @PermitAll
    @PostMapping("/unbind")
    public AjaxResult unbindRelateAcct(@RequestBody BankWithdrawal bankWithdrawal) {
        return success(bankWithdrawalService.unbindRelateAcct(bankWithdrawal));
    }
}
